import { Badge } from '/components/badge'

# File Upload Configuration

Used to configure file upload settings, including allowed file types, file size limits, etc. For file upload methods and file deletion methods, please refer to [Methods](./methods).

## Default Configuration

```js
{
  file: {
    allowedMimeTypes: [],
    maxSize: 1024 * 1024 * 100, // 100M
    preview: [ // Added in v5.0.0
      { extensions: ['pdf'], url: '{url}' },
      {
        extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
        url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&amp;wdStartOn=1&amp;wdPrint=0&amp;wdEmbedCode=0',
      },
    ],
  },
}
```

## Configuration Options

### file.allowedMimeTypes

**Description**: Allowed file types for upload. An empty array means all file types are allowed.

**Type**: `Array`

**Default Value**: `[]`.

**Optional Values**:

Valid [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).

Additionally, if you want to upload files of the same type, you can use `*` to simplify the configuration. For example, to allow all images, you can configure it as `['image/*']`.

### file.maxSize

**Description**: The maximum size of files allowed for upload, in bytes (B).

**Type**: `Number`

**Default Value**: `1024 * 1024 * 100` (100M)

### file.preview 

**Description**: Configuration for file preview, including file types and preview links. Note that modifying this value will directly overwrite the default value. If you need to adjust the file preview configuration, modify it based on the default value. <Badge theme="success">Added in v5.0.0</Badge>

**Type**: `Array`

**Default Value**: 
```js
[
  { extensions: ['pdf'], url: '{url}' },
  {
    extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
    url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&amp;wdStartOn=1&amp;wdPrint=0&amp;wdEmbedCode=0',
  },
]
```

**Optional Values**:

- `preview[].extensions`: Array of supported file extensions, refer to the default value.
- `preview[].url`: Preview link, which can be a string or an array of strings. Supports `{url}` and `{{url}}` placeholders, used to replace the uploaded file's URL and encode the URL with `encodeURIComponent`, respectively.
